<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');?>
<style>
.input2 {
	border: 1px solid #C8C8C8;
	padding: 3px 5px;
}
.wrc {width:250px;}
img#loading {display:none}
</style>
<div class="page-content middle padtop10">
	<!-- bread crumb -->
	<p id="bread-crumb">
		<a href="<?php echo site_url('');?>">
			<?php echo $lang['home'];?>
        </a>
		<a href="<?php echo site_url('recharge');?>">
			<?php echo $lang['request_recharge'];?>
        </a>
		<?php echo $lang['add_money'];?>
	</p>
	<!-- end bread crumb -->
	
	<h3>
		<?php echo $lang['add_money'];?>
	</h3><br />
			
	<div class="payment-total-info myclear">
		<div style="width:50%;padding:10px; background:#fff; border: 1px solid #ccc;">
		<?php if($msg != ''){?>
		<div class="msg"><?php echo base64_decode($msg);?></div>
		<?php }?>
		<form name="frmRecharge" action="<?php echo site_url('recharge/saveMoney');?>" method="post" onsubmit="return checkRecharge();">
			<table width="100%" style="border-spacing:3px">
				<tr>
					<td width="110">
						<?php echo $lang['amount'];?>:
					</td>
					<td>
						<input class="input2 wrc" type="text" name="txtAmount" id="txtAmount" />
					</td>
				</tr>
				<tr>
					<td>
						<?php echo $lang['recieve_account'];?>:
					</td>
					<td style="padding: 5px 0;">
						<input type="radio" name="acctype" value="user" id="acc_user" />
						<label for="acc_user"><?php echo $lang['user'];?></label>
						&nbsp;|&nbsp;
						<input type="radio" name="acctype" value="agency" id="acc_agency" />
						<label for="acc_agency"><?php echo $lang['agency'];?></label>
						&nbsp;&nbsp;
						<select name="accname" id="accname" style="width:125px">
							<option value="0"><?php echo $lang['please_select'];?></option>
						</select>
						<img alt="loading" src="/images/ajaxLoading.gif" id="loading" />
					</td>
				</tr>
				<tr>
					<td width="100">
						<?php echo $lang['content'];?>:
					</td>
					<td>
						<textarea class="input2 wrc" style="height:50px" name="txtDescription" id="txtDescription"></textarea>  (<?php echo $lang['option'];?>)
					</td>
				</tr>
				<tr>
					<td>&nbsp;</td>
					<td>
						<br />
						<input class="input2" type="submit" value="<?php echo $lang['recharge'];?>" />
						<input class="input2" type="button" value="<?php echo $lang['cancel'];?>" onclick="window.location = '<?php echo site_url('recharge');?>';" />
					</td>
				</tr>
			</table>
		</form>
		</div>
	</div>
</div>
<br /><br />
<script type="text/javascript">
$(document).ready(function(){
	$('#txtAmount').setMask({mask : '999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999,999', type : 'reverse', defaultValue: '0'});
	$('input:radio[name="acctype"]').click(function(){
		var acctype = $(this).val();
		$('#loading').show();
		$.ajax({
			url: '<?php echo site_url('recharge/ajaxGetAccName');?>/?acctype=' + acctype,
			success: function(data){
				$('#accname').html(data);
				$('#loading').hide();
			}
		});
	});
});
function checkRecharge()
{
	var value = $('#txtAmount').val();
	value = value.replace(/,/g, '');
	var acctype = $('input:radio[name="acctype"]:checked').val();
	if(value == '' || !isIntNumber(value))
	{
		alert('<?php echo $lang['enter_amount'];?>');
		return false;
	}

	value = $('#accname').val();
	if(value == '0' || (acctype != 'user' && acctype != 'agency'))
	{
		alert('<?php echo $lang['enter_user'];?>');
		return false;
	}

	return true;
}
</script>